package com.genesis.yunnanji.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.genesis.yunnanji.R;
import com.genesis.yunnanji.bean.ExplorationRoomBean;
import com.genesis.yunnanji.config.GenesisApiConfig;

import java.util.List;

/**
 * 创建日期：2018/10/30 0030
 * 作者：Kite
 * 描述：
 */
public class OneAdapter extends BaseQuickAdapter<ExplorationRoomBean.ResultBean.ListBean.DataBean, BaseViewHolder> {

    private Context mContext;

    public OneAdapter(Context mContext, int layoutResId, @Nullable List<ExplorationRoomBean.ResultBean.ListBean.DataBean> data) {
        super(layoutResId, data);
        this.mContext = mContext;
    }

    @Override
    protected void convert(BaseViewHolder helper, ExplorationRoomBean.ResultBean.ListBean.DataBean item) {
        helper.setText(R.id.tv_name, item.getTitle());
        TextView tvName = helper.getView(R.id.tv_name);
        ViewGroup.LayoutParams layoutParams = tvName.getLayoutParams();
        layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        tvName.setLayoutParams(layoutParams);
        tvName.setMaxLines(1);
        tvName.setEllipsize(TextUtils.TruncateAt.END);
        Glide.with(mContext).load(GenesisApiConfig.PIC_HOST + item.getCover_img()).into((ImageView) helper.getView(R.id.iv_img));
    }

}
